flowchart TB A[Dataset] --> B(GEE) B --> C[export tif] C --> D[QGIS] D --> E[Zonal statistics] E --> F(import in R) F --> G[plot with leaflet]
Spatial analysis in R
tools
GIS
R
Workflow
After several tentative of connecting Google Earth Engine and R via rgee, I had to abandon this idea and make a different workflow. The initial idea was to export geojson files from GEE and plot them in R. In some cases there were errors with GEOMETRYCOLLECTION features that blocked both leaflet and mapview. I then switched to this workflow, using QGIS for intermediate calculations.
Printing vector data
The first example will use a geojson file created from Google Earth Engine indicating the population in each administrative district of Sweden.
Printing with ‘sf’ package
plot(data_map[,14],max.plot = 14)
Printing with ‘ggplot’ package
ggplot(data_map) + geom_sf(aes(fill = sum)) +
scale_fill_viridis() + theme_bw()
Printing with ‘leaflet’ package
leaflet()%>%
addTiles()%>%
addPolygons(data= zonal)